home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 806 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: A couple of questions about strings
  5. Date: 21 Mar 1996 11:13:00 PST
  6. Organization: GABI Software, Sarl.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <KANZE.96Mar21165742@gabi.gabi-soft.fr>
  9. References: <3150756f.168603020@sqarc.sq.com>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 21 Mar 1996 15:57:42 GMT
  12. In-Reply-To: willer@carolian.com's message of 20 Mar 1996 22:11:25 GMT
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMVGq40y4NqrwXLNJAQEJpgIAxV0mS0d+Fj1OP3l9HRb5aleAHP6GrxWh
  15.     jjy1CG9MVuM7XD6+IGoyEciXgkzydOMKolXGiD7FSSR9I5b/r5TWcw==
  16.     =k6i/
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article <3150756f.168603020@sqarc.sq.com> willer@carolian.com (Steve
  20. Willer) writes:
  21.  
  22. |> I'm probably beating a dead horse here, but I had a couple of
  23. |> questions about the strings class (at least, the one in the April WP).
  24. |> Specifically, there are two design decisions that I don't understand.
  25.  
  26. |> a) Why does basic_string::copy() not also copy an ending '\0'? If
  27. |> there's some sort of good reason, why wasn't a function added that did
  28. |> this (perhaps basic_string::copy_null() or something)? I must say, it
  29. |> is very inconvenient to copy a string to a C-style array of chars with
  30. |> the current string class.
  31.  
  32. Perhaps because it is so easy to write:
  33.  
  34.     dst[ s.copy( dst , sizeof( dst ) - 1 ) ] = '\0' ;
  35.  
  36. I'll admit that I don't particularly care for this style: too many side
  37. effects in the indexing expression for readability.  But it does fit in
  38. with the C/C++ tradition.
  39.  
  40. |> b) I don't see any reason why basic_string::copy() is not a const
  41. |> function. Any particular reason for that one?
  42.  
  43. In my copy of the draft, it is const.
  44. -- 
  45. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  46. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  47. Conseils en informatique industrielle --
  48.                             -- Beratung in industrieller Datenverarbeitung
  49. ---
  50. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  51.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  52.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  53.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  54.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  55. ]
  56.